<?php
require_once 'config.php';
?>
<?php 
    /* 根据书籍编号查找书本信息
     * @param bookid
     * @return array   
     * @author zhangmanya * */

function findbookId($bookId)//条件判断
{
    
    $sqlGet="SELECT * FROM book WHERE bookId='$bookId'";
    $result=getQuery($sqlGet);
    if (count($result)>0)
    {
        return $result[0];
    }
    return $result; //返回数组
}


/* 根据版块编号查找版块信息
 * @param sectionId
 * @return array*rows
 * @author zhangmanya
 *   * */
function findsectionId($sectionId)//条件判断
{
    
    $sqlGet="SELECT * FROM book,Section WHERE book.sectionId=Section.sectionId and book.sectionId='$sectionId'";
    $result=getQuery($sqlGet);
    return $result; //返回数组
}
/* 根据版块编号查找 书本信息和对应的版块信息
 * @param sectionId
 * @return array
 * @author zahngmanya*/
function findsectionIdName($sectionId)//条件判断
{
    
    $sqlGet="SELECT * FROM book,Section WHERE book.sectionId=Section.sectionId and book.sectionId='$sectionId'";
    $result=getQuery($sqlGet);
    if (count($result)>0)
    {
        return $result[0];
    }
    return $result; //返回数组
}



/* 根据书本编号头像查找书本头像
 * @param bookpic
 * @return array
 * @author zhangmanya   * */
function findbookPic($bookPic)//条件判断
{   
    $sqlGet="SELECT * FROM book WHERE bookPic='$bookPic.jpg'";
    $result=getQuery($sqlGet);
    return $result; //返回数组
}


/* 查找所有书籍查找书籍
 * 
 * @return array
 * @author huangchuting
 *  */
function getbook(){
    $sqlGet="SELECT * FROM book  ORDER BY sectionId ASC";
    $result=getQuery($sqlGet);
    return $result; //返回数组
}


/* 统计指定板块发表帖子的总数 
 * @param sectionId
 * @return array
 * @author zhangmanya
 * */
function findCountbook($sectionId){
    $strQuery = "select count(*) as nums from book where  sectionId = $sectionId ";
    $rs = getQuery($strQuery);//执行统计
    $value = 0;
    if(count($rs)>0){//判断是否成功执行
        $value = $rs[0]["nums"];
    }
    return $value;
}


/* 书本分页 
 * @param page sectionId
 * @return  array*rows
 * @author zhangmanya
 * */
function findListbook($page,$sectionId){
    $pageSize=$GLOBALS["cfg"]["server"]["page_size"];
    if($page >= 1){//分页处理
        $page --;
    }
    $page *= $pageSize;
    //分页查询
    $strQuery = "SELECT * FROM book,Section WHERE book.sectionId=Section.sectionId and  book.sectionId=$sectionId order by bookId  limit $page,$pageSize";
    $rs = getQuery($strQuery);//执行查询
    return $rs;
}

//2020.6.5 huguoli
/* 根据标签编号查找标签
 * @return array
 *  */
function findRevLabel($labelId){
    $sqlGet="SELECT * FROM label where labelId=$labelId";
    $result=getQuery($sqlGet);
    if (count($result)>0)
    {
        return $result[0];
    }
    return $result; //返回数组
}

/* 根据书籍编号查找书评
 * @return array
 *  */
function findReview($bookId){
    $sqlGet="SELECT * FROM review where bookId=$bookId";
    $result=getQuery($sqlGet);
    return $result; //返回数组
}




?>